package sweng.cholesky.business;

import java.awt.Dimension;

import sweng.cholesky.calculation.Util;
/**
 * The Matrix Class ... It's Neo Time...
 * @author Bernd
 *
 */
public class Matrix {
	public double[][] matrixIn;
	public double[][] matrixZerlegt;
	public double[][] matrixInvertiert;
	public double[][] matrixKontroll;
	Dimension d;
	int rows;
	int columns;
/**
 * Creates a Matrix Object out of a double array
 * @param matrix
 */
	public Matrix(double[][] matrix) {
		this.matrixIn = matrix;
		d = getDimension();
		rows = getRows();
		columns = getColumns();
		this.matrixZerlegt = Util.copyDeep(matrix);
	}
/**
 * Get the Dimension of the Matrix
 * @return dimension(columns,rows)
 */
	public Dimension getDimension() {
		return new Dimension(getColumns(), getRows());
	}
/**
 * Get the Rows of the Matrix
 * @return rows
 */
	public int getRows() {
		return matrixIn.length;
	}
/**
 * Get the Columns of the Matrix
 * @return getColumns
 */
	public int getColumns() {
		return matrixIn[0].length;
	}
	/**
	 * This method prints the Elements of the Matrix
	 */
public void print(){
	if(columns<100 && rows<100)
try {
		for (int i = 0; i < getRows(); i++) {
			for (int k = 0; k < getColumns(); k++) {
				System.out.print(matrixZerlegt[i][k] + "\t");
			}
			System.out.print("\n");
		}} catch (Exception e) {
			// TODO: handle exception
		}
		else {
			System.out.println(toString());
		}
}
/**
 * Returns several information about the Matrix
 */
	public String toString() {
		if (this.getColumns() == 1){
			return "A Vector with " + this.getRows() + " Rows!";

		}
		else {
			
		}
		return "A Matrix with " + this.getRows() + " Rows and " + this.getColumns() + " Columns!";

	}
}
